package com.yunhe.merchants.client;


import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ModelNotFoundException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.User;
import com.yunhe.common.model.company.ContractAccessories;
import com.yunhe.merchants.client.fallback.AuthorityClientFallbackFactory;
import com.yunhe.merchants.config.FeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;


/**
 * @ClassName OrgClient
 * @Description TODO
 * @Author HeTao
 * @Date 2021/5/10 16:04
 * @Version 1.0
 **/
@ApiIgnore
@FeignClient(value = "yh-authority", fallbackFactory = AuthorityClientFallbackFactory.class,configuration = FeignConfig.class)
@Component
public interface AuthorityClient {

    @RequestMapping(value = "/organization/getSubOrg", method = RequestMethod.GET)
    ResponseEntity<ResultObject> getSubOrg(@RequestParam(value = "orgId") String orgId);

    @RequestMapping(value = "/organization/getOrgByLoginUser", method = RequestMethod.GET)
    ResponseEntity<ResultObject> getOrgByLoginUser(@RequestParam(value = "firmId", required = false) Long firmId,
                                                   @RequestParam(value = "stationId", required = false) Long stationId,
                                                   @RequestParam(value = "orgFunction", required = true) String orgFunction,
                                                   @RequestParam(value = "childFlag", required = true) Boolean childFlag);

    @RequestMapping(value = "/office/getOfficeById", method = RequestMethod.GET)
    ResponseEntity<ResultObject> getOfficeById(@RequestParam("id") Long officeId);

    @RequestMapping(value = "/users/getUserByStationIdAndOrg", method = RequestMethod.GET)
    ResponseEntity<ResultObject> getUserByStationIdAndOrg( @RequestParam(value = "stationId") Long stationId,
                                                           @RequestParam(value = "orgIds") List<Long> orgIds,
                                                           @RequestParam(value = "roleName") String roleType);
    @RequestMapping(value = "/users/getUserByPhone",method = RequestMethod.GET)
    ResponseEntity<ResultObject> getUserByPhone (@RequestParam(value = "phone",required = true) String phone);

    @RequestMapping(value = "/users/getUserByOrgAndRoleName", method = RequestMethod.GET)
    ResponseEntity<ResultObject> getUserByOrgAndRoleName(@RequestParam(value = "orgId",required = true) Long orgId,
                                                                @RequestParam(value = "roleName",required = true) String roleName,
                                                                @RequestParam(value = "stationId",required = false) Long stationId,
                                                                @RequestParam(value = "firmId",required = false) Long firmId);

    @RequestMapping(value = "/organization/searchOrgByStationIdOrFirmId", method = RequestMethod.GET)
    ResponseEntity<ResultObject> searchOrgByStationId(@RequestParam(value = "stationId", required = false) Long stationId,
                                                      @RequestParam(value = "firmId", required = false) Long firmId);

    @RequestMapping(value = "/users/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<User>> get(@PathVariable("id") Long id);

    @RequestMapping(value = "/office/findByStationIdAndOfficeTitle/{stationId}", method = RequestMethod.GET)
    ResponseEntity<ResultObject> findByStationIdAndOfficeTitle(@PathVariable("stationId") Long stationId,
                                                                      @RequestParam(value = "officeTitle") String officeTitle);

    /**成功项目录入在园项目*/
    @RequestMapping(value = "/companyFeign/intentionToCompany", method = RequestMethod.POST)
    ResponseEntity<ResultObject<String>> intentionToCompany(@RequestParam(value = "intentionId", required = true) Long intentionId,
                                                            @RequestParam(value = "officeIds", required = false) String officeIds,
                                                            @RequestParam(value = "title", required = true) String title,
                                                            @RequestParam(value = "leaseTime", required = true) String leaseTime,
                                                            @RequestParam(value = "leaseDueTime", required = true) String leaseDueTime,
                                                            @RequestBody List<ContractAccessories> contractAccessoriesList)
            throws ObjectNotFoundException, UniqueConstraintsException, ArgumentErrorException;

    @RequestMapping(value = "/office/setOfficeBooked", method = RequestMethod.POST)
    ResponseEntity<ResultObject> setOfficeStatus(@RequestParam(value = "intentionId", required = true) Long intentionId,
                         @RequestParam(value = "chosenOffice", required = true) Long chosenOffice,
                         @RequestParam(value = "companyName", required = true) String companyName,
                         @RequestParam(value = "stauts", required = true) String stauts) throws ArgumentErrorException, ModelNotFoundException, ModelNotFoundException;
}
